const senku = init()
const jsname = '韩康健康打卡'
url = "https://yjsxx.whut.edu.cn/wx/./monitorRegister";
const body = "{\"diagnosisName\":\"\",\"relationWithOwn\":\"\",\"currentAddress\":\"\u6c5f\u82cf\u7701\u5f90\u5dde\u5e02\u90b3\u5dde\u5e02\",\"remark\":\"\",\"healthInfo\":\"\u6b63\u5e38\",\"isDiagnosis\":0,\"isFever\":0,\"isInSchool\":0,\"isLeaveChengdu\":1,\"isSymptom\":0,\"temperature\":\"36\\\"C~36.5\u00b0C\",\"noonTemperature\":\"36.5\u00b0C~36.9\u00b0C\",\"eveningTemperature\":\"36.5\u00b0C~36.9\u00b0C\",\"province\":\"\u6c5f\u82cf\u7701\",\"city\":\"\u5f90\u5dde\u5e02\",\"county\":\"\u90b3\u5dde\u5e02\"}";
const headers = {
    "Cookie": "JSESSIONID=0c963631-a7f5-44f4-8352-914cf8b9bed3",
    "Content-Type": "application/json",
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "Connection": "keep-alive",
    "X-Tag": "flyio",
    "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.17(0x1700112a) NetType/WIFI Language/zh_CN",
    "Referer": "https://servicewechat.com/wx225eb50c34f6f98e/6/page-frame.html",
    "Content-Length": "380",
    "Accept-Language": "zh-cn"
};
const request = {
    url: url,
    headers: headers,
    body: body
};

senku.post(request, function (error, response, data) {
    try {
        senku.log(data)
        const res = JSON.parse(data)
        senku.msg(jsname, '', res.message)//这里是以后要写的代码,大概几行就写完了
        senku.done();

    } catch (e) {
        senku.log(e)
        senku.done();
    }
});

function init() {
    isSurge = () => {
        return undefined === this.$httpClient ? false : true
    }
    isQuanX = () => {
        return undefined === this.$task ? false : true
    }
    getdata = (key) => {
        if (isSurge()) return $persistentStore.read(key)
        if (isQuanX()) return $prefs.valueForKey(key)
    }
    setdata = (key, val) => {
        if (isSurge()) return $persistentStore.write(key, val)
        if (isQuanX()) return $prefs.setValueForKey(key, val)
    }
    msg = (title, subtitle, body) => {
        if (isSurge()) $notification.post(title, subtitle, body)
        if (isQuanX()) $notify(title, subtitle, body)
    }
    log = (message) => console.log(message)
    get = (url, cb) => {
        if (isSurge()) {
            $httpClient.get(url, cb)
        }
        if (isQuanX()) {
            url.method = 'GET'
            $task.fetch(url).then((resp) => cb(null, resp, resp.body))
        }
    }
    post = (url, cb) => {
        if (isSurge()) {
            $httpClient.post(url, cb)
        }
        if (isQuanX()) {
            url.method = 'POST'
            $task.fetch(url).then((resp) => cb(null, resp, resp.body))
        }
    }
    done = (value = {}) => {
        $done(value)
    }
    return {
        isSurge,
        isQuanX,
        msg,
        log,
        getdata,
        setdata,
        get,
        post,
        done
    }
}

